/**
 * Created by yhg97p on 2016/9/26.
 */
'use strict';

/* Filters */

define(['app'], function (app) {
    'use strict';
    /* Filters */
    app.register.filter('numPrefix', function () {
        return function (num) {
            return new Array(2).join('0').concat(num);
        };
    });
    app.register.filter('timeFormat', function () {
        return function (time) {
            if (time) {
                var newTime = time.substring(5, time.length - 3).replace('-', '.');
                return newTime;
            }
        }
    })
    app.register.filter('videoDate', function () {
        return function (time) {
            var new_time =(time-new Date(time).getTimezoneOffset())/1000;
            var h = Math.floor(new_time/3600);
            if(h<10){
                h= "0"+h
            }
            var m = Math.floor((new_time-3600*h)/60);
            if(m<10){
                m= "0"+m
            }
            var s = Math.floor(new_time-3600*h-m*60);
            if(s<10){
                s= "0"+s
            }
            return h+":"+m+":"+s;
        };
    });
    app.register.filter('getYear', function () {
        return function (time) {
            if(time){
                var year = time.substring(0,4);
                return year;
            }

        };
    });
    app.register.filter('getMonth', function () {
        return function (time) {
            if(time){
                var month = time.substring(5,7);
                return month;
            }

        };
    });
    app.register.filter('check_score', function () {
        return function (score,index,item) {
            if(score > 90){
                score = 90;
            }
            if(score < 10){
                score = 10;
            }
            var showScore = Math.floor((score/100)*535);
            $('.report_page').find('.progressBar_box').eq(index).find('#progressBar').css('width',showScore);
        };
    });
});